Example:The following example shows how to use a structure element.
import com.cete.dynamicpdf.*;
import com.cete.dynamicpdf.pageelements.*;
import java.io.FileNotFoundException;
public class MyClass{
public static void main(String args[]){
// Create a PDF Document
Document document = new Document();
// Specify document as a tagged PDF
document.setTag(new TagOptions());
// Create a page and add it to the document
Page page = new Page();
document.getPages().add(page);
try{
// Create an image
Image image = new Image("[physicalpath]/MyImage.jpg", 100, 100);
image.setHeight(100);
image.setWidth(100);
// Create a structue element
StructureElement structureElement = new StructureElement(TagType.getFigure(), true);
structureElement.setAlternateText("My Image");
// Tag the image with the structure element
image.setTag(structureElement);
// Add the image to the page
page.getElements().add(image);
}
catch (FileNotFoundException ex1) {
System.err.println("Image file not found :"+ex1);
}
//Save the PDF
document.draw("[PhysicalPath]/MyDocument.pdf" );
}
}